package com.lyz.myself.controller;

import com.lyz.myself.config.dozer.EJBGenerator;
import com.lyz.myself.config.utils.JwtUtil;
import com.lyz.myself.config.utils.Result;
import com.lyz.myself.config.utils.base.CodeMsg;
import com.lyz.myself.config.utils.oss.AliyunOSSUtil;
import com.lyz.myself.config.utils.oss.ConstantProperties;
import com.lyz.myself.config.utils.util.DateUtil;
import com.lyz.myself.config.utils.util.LogUtils;
import com.lyz.myself.pojo.Po.FileLeads;
import com.lyz.myself.pojo.Po.RFileLeads;
import com.lyz.myself.pojo.Po.User;
import com.lyz.myself.pojo.Po.common.Constant;
import com.lyz.myself.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class BaseController {

    @Autowired
    protected EJBGenerator ejbGenerator = new EJBGenerator();
    protected final Logger log = LogUtils.getExceptionLogger();
    @Autowired
    private UserService userService;

    public User getUser() {
        Subject subject = SecurityUtils.getSubject();
        String token = String.valueOf(subject.getPrincipal());
        String name = JwtUtil.getClaim(token, Constant.NAME);
        return userService.selectByPrimaryKey(Integer.valueOf(name));
    }

    public static String TABLENAME;

    public String getTableName() {
        return TABLENAME = "5kcrm";//全局变量数据库表名
    }

}
